<?php

namespace maotool\util;

/**
 * 唯一编号
 */
class IdUtil
{

    /**
     * 生成UUID
     * @return string
     */
    public static function randomUUID()
    {
        $chars = md5(uniqid(mt_rand(), true));
        return substr($chars, 0, 8) . '-'
            . substr($chars, 8, 4) . '-'
            . substr($chars, 12, 4) . '-'
            . substr($chars, 16, 4) . '-'
            . substr($chars, 20, 12);
    }

    /**
     * 不加符号的UUID
     * @return array|string|string[]
     */
    public static function simpleUUID()
    {
        return str_replace("-", "", self::randomUUID());
    }

}